<h1>Docker logs 命令</h1>
<p><strong>docker logs : </strong>获取容器的日志</p>
<h3>语法</h3>
<pre><code class="language-Docker">docker logs [OPTIONS] CONTAINER</code></pre>
<p>OPTIONS说明：</p>
<ul>
<li><p><strong>-f : </strong>跟踪日志输出</p></li>
<li><p><strong>--since :</strong>显示某个开始时间的所有日志</p></li>
<li><p><strong>-t : </strong>显示时间戳</p></li>
<li><p><strong>--tail :</strong>仅列出最新N条容器日志</p></li>
</ul>
<h3>实例</h3>
<p>跟踪查看容器mynginx的日志输出。</p>
<pre><code class="language-Docker">runoob@runoob:~$ docker logs -f mynginx

192.168.239.1 - - [10/Jul/2016:16:53:33 +0000] "GET / HTTP/1.1" 200 612 "-" "Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/45.0.2454.93 Safari/537.36" "-"

2016/07/10 16:53:33 [error] 5#5: *1 open() "/usr/share/nginx/html/favicon.ico" failed (2: No such file or directory), client: 192.168.239.1, server: localhost, request: "GET /favicon.ico HTTP/1.1", host: "192.168.239.130", referrer: "http://192.168.239.130/"

192.168.239.1 - - [10/Jul/2016:16:53:33 +0000] "GET /favicon.ico HTTP/1.1" 404 571 "http://192.168.239.130/" "Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/45.0.2454.93 Safari/537.36" "-"

192.168.239.1 - - [10/Jul/2016:16:53:59 +0000] "GET / HTTP/1.1" 304 0 "-" "Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/45.0.2454.93 Safari/537.36" "-"

...


</code></pre>
<p>查看容器mynginx从2016年7月1日后的最新10条日志。</p>
<pre><code class="language-Docker">docker logs --since="2016-07-01" --tail=10 mynginx</code></pre>
